#include "String.h"

void test()
{
	//string s("123456789012345");
	//cout << s.size() << endl << s.capacity() << endl;
	//String s3;
	//String s2(s);
	//cout << s << endl << s2 << endl;
	//cin >> s2;
	//cout << s2;
	String s3("hello, world");
	for (size_t i = 0; i < s3.size(); i++)
	{
		cout << s3[i] << " ";
	}
	cout << endl;
	const String s4("hello, world");
	for (size_t i = 0; i < s4.size(); i++)
	{
		cout << s4[i] << " ";
	}
	cout << endl;

	String::iterator it = s3.begin();
	while (it != s3.end())
	{
		cout << ++(*it) << " ";
		++it;
	}
	cout << endl;

	String::const_iterator it2 = s4.begin();
	while (it2 != s4.end())
	{
		cout << *it2 << " ";
		++it2;
	}
	cout << endl;

	for (auto e : s4)
	{
		cout << e << " ";
	}
	cout << endl;
}

void test2()
{
	String s("hello, world");
	s.push_back('A');
	s.push_back('B');
	cout << s << endl;

	s.append("nihaoya shijie");
	cout << s << endl;
}

void test3()
{
	//String s("hello, world");
	//s.erase(9);
	//cout << s << endl;

	//String s2("hello, world");
	//s2.erase(4, 3);
	//cout << s2 << endl;

	String s3("hello, world");
	s3.insert(3, 'A');
	cout << s3 << endl;

	s3.insert(0, 'B');
	cout << s3 << endl;

	s3.insert(6, "nihao shijie");
	cout << s3 << endl;

}

void test4()
{
	String s("hello, world");
	s.insert(9, "xxx");
	cout << s << endl;
}

void test5()
{
	String s("hello, world");
	String s3("hello, world");
	String s2 = s.substr(3, 6);
	
	cout << s2 << endl;
	cout << (s == s3) << endl;
	cout << (s3 == s) << endl;
	cout << ("hello, world" == s) << endl;
	cout << (s3 == "hello, world") << endl;
}

void test6()
{
	String s("hello, world");
	String s2("hello, world");
	cin >> s >> s2;
	cout << s << endl << s2 << endl;

	String s3;
	getline(cin, s3);
	cout << s3 << endl;
}

void test7()
{
	String s("hello, world");
	cin >> s;
	cout << s.capacity() << endl;
}

void test8()
{
	String s("hello, world");
	String s2("hello, shijie");

	//s.swap(s2);
	s = s2;
	cout << s << endl << s2 << endl;
	

}

int main()
{
	test8();
	//string s;
	//cin >> s;
	//cout << s;



	return 0;
}